﻿/***************************************************************************
//* Foxit Software Inc.
//* Copyright(C) 2005-2012, all rights reserved.
//*
//* The following code is copyrighted and contains proprietary information
//* and trade secrets of Foxit Software Inc.                                                      *
***************************************************************************/
/**
* PDF Destination
*/
define(function (require, exports, module) {
    require('../DataLevel.js');
    WebPDF.PDFData.DestinationInfoJsonFormat = {
        left: "l",
        top: "t",
        width: "w",
        height: "h",
        pageIndex: "p",
        zoomToMode: "zm",
        scale: "s",
        bPdfCord: "bp",
        bLink: "bl",
        offsetX: "x",
        offsetY: "y"
    };
    var DestinationInfoJsonFormat = WebPDF.PDFData.DestinationInfoJsonFormat;

    WebPDF.PDFData.PDFDestination = function (jsonData) {
        this.left = -1;
        this.top = -1;
        /**
         * 宽度
         * @type {number}
         */
        this.width = -1;
        /**
         * 高度
         * @type {number}
         */
        this.height = -1;
        /**
         * 页面索引
         * @type {number}
         */
        this.pageIndex = 0;
        /**
         * 缩放模式
         * @type {number}
         */
        this.zoomToMode = 0;
        /**
         * 缩放比例
         * @type {number}
         */
        this.scale = 1.0;
        /**
         * 是否为PDF坐标
         * @type {boolean}
         */
        this.bPdfCord = true;
        /**
         * 是否是一个Link
         * @type {boolean}
         */
        this.bLink = true;

        /**
         * Parse JSON data to PDFDestination.
         * @param {JSON} destinationJSONData
         */
        this.parseJSONData = function (destinationJSONData) {
            this.left = destinationJSONData[DestinationInfoJsonFormat.left];
            this.top = destinationJSONData[DestinationInfoJsonFormat.top];
            this.width = destinationJSONData[DestinationInfoJsonFormat.width];
            this.height = destinationJSONData[DestinationInfoJsonFormat.height];
            this.pageIndex = destinationJSONData[DestinationInfoJsonFormat.pageIndex];
            this.zoomToMode = 0; // destinationJSONData.zm; 目前忽略掉缩放模式
            this.dbScale = destinationJSONData[DestinationInfoJsonFormat.scale];
            this.bPdfCord = destinationJSONData[DestinationInfoJsonFormat.bPdfCord] == 1 ? true : false;
            this.bLink = destinationJSONData[DestinationInfoJsonFormat.bLink] == 1 ? true : false;
        };

        this.parseJSONData(jsonData);
    };
    return WebPDF.PDFData.PDFDestination;
});